@spreadsheet-first-tool-offset: .3em;
@spreadsheet-popup-button-padding: .3em 1.5em .3em .9em;
.force-font() {
    font-size: 12px;
    font-family: Arial, Verdana, sans-serif;
}

.k-spreadsheet {
    width: 800px;
    height: 600px;

    border-width: 1px;
    border-style: solid;

    cursor: default;

    .k-spreadsheet-pane {
        td {
            white-space: nowrap;
            border-width: 1px;
            border-style: solid;
            box-sizing: border-box;
            overflow: hidden;
            height: 20px;
            user-select: none;
        }

        table {
            table-layout: fixed;
            border-collapse: collapse;
            box-sizing: border-box;
            position: absolute;

            &.k-spreadsheet-merged-cell {
                width: auto;
                height: auto;
            }

            &.k-spreadsheet-row-header {
                width: auto;

                td {
                    border-left-width: 0;
                }
            }

            &.k-spreadsheet-column-header {
                height: auto;

                td {
                    border-top-width: 0;
                }
            }
        }
    }

    .k-spreadsheet-selection,
    .k-spreadsheet-active-cell {
        border-width: 1px;
        border-style: solid;
        position: absolute;
        box-sizing: border-box;
    }

    .k-spreadsheet-active-cell {
        &.k-left { border-left-width: 0; }

        td {
            border-width: 0 !important;
        }
    }

    @formula-bar-height: 26px;
    @formula-input-height: @formula-bar-height / 1.3;
    @formula-input-padding: (@formula-bar-height - @formula-input-height) / 2;

    .k-spreadsheet-formula-bar {
        border-width: 1px;
        border-style: solid;
        padding-left: 31px; // XXX: Move to code
        position: relative;
        .force-font();

        &:before {
            .use-font-icon();
            content: "\e659";
            display: block;
            height: @formula-input-height;
            top: @formula-input-padding;
            border-width: 0 1px 0 0;
            border-style: solid;
            position: absolute;
            width: 24px;
            margin-left: -24px;
        }

        &:after {
            content: "";
            display: block;
            border-width: 0 0 1px;
            border-style: solid;
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
        }
    }

    .k-spreadsheet-formula-input {
        outline: none;
        border-width: 0;
        height: @formula-bar-height;
        line-height: @formula-input-height;
        width: 100%;
        box-sizing: border-box;
        white-space: nowrap;
        padding: @formula-input-padding .5em 0;
    }

    .k-spreadsheet-cell-editor {
        position: absolute;
        display: none;
        padding: 0 .3em;
        line-height: @formula-input-height;
        z-index: 2000;
        overflow: hidden;
    }

    > .k-spreadsheet-view {
        position: relative;
        .force-font();
    }

    .k-tabstrip-wrapper {
        position: relative;
        line-height: 1.7em;

        .k-tabstrip-items {
            padding: @spreadsheet-first-tool-offset 0 0;
        }
    }

    .k-spreadsheet-quick-access-toolbar {
        display: inline-block;
        position: absolute;
        z-index: 1;
        top: 0;
        left: 0;
        padding: @spreadsheet-first-tool-offset @spreadsheet-first-tool-offset 0;

        .k-button {
            padding: .3em;
            line-height: 1.4em;
        }
    }

    .k-merged-cells-wrapper,
    .k-selection-wrapper,
    .k-filter-headers,
    .k-spreadsheet-column-header {
        position: relative;
    }

    .k-spreadsheet-sheets-bar {
        border-width: 1px 0 0;
    }
    
    .k-dirty-cell {
        position: relative;
    }
    
    .k-dirty {
        right: 0;
        margin: -2px 0 0 -7px;
        border-width: 4px;
        border-color: #f00 #f00 transparent transparent;
    }
}

.k-font-icon,
.k-font-icon.k-icon,
.k-font-icon.k-tool-icon {
    .use-font-icon();
    background-image: none;
    font-size: 16px;
}

.k-spreadsheet .k-colorpicker .k-tool-icon {
    overflow: visible;
}

.k-spreadsheet-filter {
    position: absolute;
    cursor: pointer;
}

.k-spreadsheet-sample {
    float: right;
}

.k-spreadsheet-clipboard-paste,
.k-spreadsheet-clipboard {
    position: absolute;
    opacity: 0;
    top: 0;
    left: 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
    border: 0;
    width: 1px;
    height: 1px;
    box-sizing: border-box;
}

.k-spreadsheet-top-corner {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10000;
    border-width: 0 1px 1px 0;
    border-style: solid;

    &:after {
        content: "";
        display: block;
        width: 0;
        height: 0;
        overflow: hidden;
        position: absolute;
        bottom: 0;
        right: 0;
        border-width: 6px;
        border-style: solid;
    }
}

.k-spreadsheet-scroller {
    width: 100%;
    height: 100%;
    overflow: scroll;
    -webkit-overflow-scrolling: touch;
    position: absolute;
    z-index: 1;
}

.k-spreadsheet-fixed-container {
    position: absolute;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    z-index: 2;
}

.k-spreadsheet-view-size {
    position: relative;
}

.k-spreadsheet-pane {
    padding-right: 1px;
    position: absolute;
    border-width: 1px;
    border-style: solid;
    overflow: hidden;
    box-sizing: border-box;

    &.k-top { border-top-width: 0; }
    &.k-left { border-left-width: 0; }
}

.k-spreadsheet-column-header,
.k-spreadsheet-row-header {
    text-align: center;
}

.k-spreadsheet-window {
    .k-root-tabs {
        border-width: 0;
        margin: -1em -1em 0;
        padding: .5em 1em 0;

        .k-loading {
            display: none;
        }
    }

    .k-list-wrapper {
        padding: .15em 0;
        border-width: 1px;
        border-style: solid;
        height: 190px;
    }

    .k-list {
        .k-item {
            border-radius: 0;
            padding: .5em .6em .4em .6em;
            cursor: pointer;
            line-height: 1.1em;
        }
    }

    .k-format-filter {
        width: 100%;

        + .k-group-header + .k-list-wrapper {
            margin-top: 1em;
        }
    }

    .k-action-buttons {
        padding: 1em;
    }
}

.k-spreadsheet-format-cells {
    .k-spreadsheet-preview {
        font-weight: bold;
        text-align: center;
        font-size: 1.16em;
        line-height: 3.64em;
        margin: 0 -.863em .72em;

        border-style: solid;
        border-width: 1px 0;
    }
}

.k-spreadsheet-border-palette {
    width: 153px;

    .k-colorpalette {
        vertical-align: bottom;
    }
}

.k-spreadsheet-popup {
    .k-separator {
        width: 1px;
        height: 1.8em;
        vertical-align: middle;
        display: inline-block;
    }

    .k-colorpalette {
        vertical-align: top;
    }

    .k-button.k-button-icon {
        padding: 0.6em;
        border-width: 0;
        border-radius: 0;
    }

    .k-button.k-button-icontext {
        display: block;
        text-align: left;
        text-transform: initial;
        padding: @spreadsheet-popup-button-padding;
        border-width: 0;
        border-radius: 0;
    }
}

.k-spreadsheet-filter-menu {
    width: 280px;

    > .k-menu {
        border-width: 0;

        .k-link {
            padding-left: 26px;
        }

        .k-icon.k-font-icon {
            margin-left: -26px;
            width: 26px;
        }
    }

    .k-spreadsheet-value-treeview-wrapper {
        height: 200px;
        overflow-y: scroll;
        overflow-x: auto;
        border-width: 1px;
        border-style: solid;

        .k-treeview {
            overflow: visible;
            padding: 6px 7px;
        }
    }

    .k-details {
        border-top-width: 1px;
        border-top-style: solid;
        padding: 4px 0;
    }

    .k-details-summary {
        cursor: pointer;
        line-height: 26px;

        .k-icon {
            margin: 0 5px;
        }
    }

    .k-details-content {
        padding: 0 8px 0 26px;

        > .k-textbox,
        > .k-widget {
            width: 100%;
            margin-bottom: 3px;
        }

        .k-space-right {
            background-image: none;
        }

        .k-filter-and {
            width: 75px;
            margin: 8px 0;
        }
    }

    .k-action-buttons {
        border-top-width: 0;
        margin: 8px;
        padding: 0;
        position: static;
    }
}

.k-resize-handle,
.k-resize-hint {
    position: absolute;
}

.k-resize-hint-handle {
    width: 100%;
    height: 20px;
}

.k-resize-hint-marker {
    width: 2px;
    height: 100%;
    margin: 0 auto;
}

.k-resize-hint-vertical .k-resize-hint-handle {
    height: 100%;
    width: 20px;
    float: left;
}

.k-resize-hint-vertical .k-resize-hint-marker {
    height: 2px;
    width: 100%;
}

.k-spreadsheet-quick-access-toolbar .k-button,
.k-button.k-spreadsheet-sheets-bar-add {
    border-color: transparent;
    background-color: transparent;
    background-image: none;
}

/* top TabStrip */

.k-spreadsheet-tabstrip {
    border-left-width: 0;
    border-right-width: 0;
    border-top-width: 0;

    > .k-content {
        border-left-width: 0;
        border-right-width: 0;
        border-bottom-width: 0;
        margin: 0;
        padding: 0;
    }

    .k-loading {
        display: none;
    }
}

.k-spreadsheet-toolbar {
    &.k-toolbar {
        border-width: 0;

        .k-overflow-anchor + * {
            margin-left: @spreadsheet-first-tool-offset;
        }
    }

    // hide button/widget default state
    > .k-widget,
    .k-button,
    > .k-button-group,
    > .k-widget .k-state-default:not(.k-state-hover):not(.k-state-active) {
        margin: 0;
        border-color: transparent;
        background-color: transparent;
        background-image: none;
    }

    > .k-widget {
        &[data-property='fontSize'] { width: 75px; }
        &[data-property='format'] { width: 100px; }
        &[data-property='fontFamily'] { width: 130px; }
    }

    > .k-combobox .k-state-default:not(.k-state-hover):not(.k-state-active) .k-input {
        background-color: transparent;
        box-shadow: none;
    }

    > .k-widget .k-state-default:not(.k-state-hover):not(.k-state-active) .k-select {
        border-color: transparent;
    }

    .k-separator {
        margin: 0 3px;
        width: 0;
        overflow: hidden;
        height: 1.8em;
        vertical-align: middle;
        display: inline-block;
    }
}

.k-spreadsheet-formula-input {
    > .k-syntax-func.k-syntax-at-point,
    > .k-syntax-bool.k-syntax-at-point,
    > .k-syntax-ref.k-syntax-at-point,
    > .k-syntax-str.k-syntax-at-point,
    > .k-syntax-num.k-syntax-at-point {
        text-decoration: underline;
    }

    > .k-series-a,
    > .k-series-b,
    > .k-series-c,
    > .k-series-d {
        background-color: transparent;
    }
}

.k-spreadsheet-selection-highlight {
    border-width: 2px;
    border-style: solid;
    position: absolute;
    box-sizing: border-box;
}

.k-spreadsheet-formula-list {
    min-width: 100px;

    .k-item {
        padding: 0 .3em;
        box-shadow: none;
    }
}

/* bottom TabStrip */

.k-spreadsheet-sheets-bar {
    position: relative;
}

.k-button.k-spreadsheet-sheets-bar-add {
    position: absolute;
    bottom: .2em;
    left: .4em;
    z-index: 1;
}

.k-tabstrip-bottom .k-spreadsheet-sheets-remove {
    padding: 0;
}

.k-spreadsheet-sheets-remove .k-button-icon {
    padding: 2px;
    line-height: normal;
}

.k-spreadsheet-sheets-remove .k-icon {
    margin: 0;
}

.k-spreadsheet-sheets-items-hint {
    margin-top: .1em;
    background: none !important;
    border-width: 0 !important;
}
